﻿
using RakutenCrawler.ConfigClass;
using RakutenCrawler.PageProcessors;

namespace RakutenCrawler.PageProcessors
{
    public class PageProcessorFactory
    {
        public static PageProcessor CreatePageProcessor(LinkConfig linkConfig, int linkId)
        {
            PageProcessor pageProcessor = null;
            switch (linkConfig.Class)
            {
                case "ProductCategoriesProcessor":
                    pageProcessor = new ProductCategoriesPageProcessor();
                    break;
                case "ProductsProcessor":
                    pageProcessor = new ProductsPageProcessor();
                    break;
                case "HomeProcessor":
                    pageProcessor = new HomePageProcessor();
                    break;
            }

            if (pageProcessor != null)
            {
                pageProcessor.LinkConfig = linkConfig;
                pageProcessor.LinkId = linkId;
            }

            return pageProcessor;
        }
    }
}
